package cn.iocoder.yudao.module.crm.dal.mysql.tasktype;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.tasktype.vo.tasktypecontent.TaskTypeContentDetail;
import cn.iocoder.yudao.module.crm.dal.dataobject.tasktype.TaskTypeAssigneeDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.tasktype.TaskTypeContentDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * CRM 任务单类型内容 Mapper
 *
 * @author 广州氪量
 */
@Mapper
public interface TaskTypeContentMapper extends BaseMapperX<TaskTypeContentDO> {
    default List<TaskTypeContentDO> getByTaskTypeId(Long id){
        return selectList(new LambdaQueryWrapperX<TaskTypeContentDO>()
                .eq(TaskTypeContentDO::getTaskTypeId, id));
    }

    default void insertBatchByTaskTypeId(List<TaskTypeContentDetail> content, Long taskTypeId){
        content.forEach(item -> {
            TaskTypeContentDO taskTypeContentDO =  new TaskTypeContentDO();
            taskTypeContentDO.setTaskTypeId(taskTypeId);
            taskTypeContentDO.setName(item.getName());
            taskTypeContentDO.setInputMethod(item.getInputMethod());
            insert(taskTypeContentDO);
        });
    }

    default void deleteBatchByTaskTypeId(Long taskTypeId){
        delete(new LambdaQueryWrapperX<TaskTypeContentDO>().eq(TaskTypeContentDO::getTaskTypeId, taskTypeId));
    }

    default List<TaskTypeContentDO> selectListByTaskTypeId(Long taskTypeId){
        return selectList(new LambdaQueryWrapperX<TaskTypeContentDO>().eq(TaskTypeContentDO::getTaskTypeId, taskTypeId));
    }
}